package com.yc.hwc.bean;

import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

@Entity
@Table
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class TaskLog implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Column(columnDefinition = "timestamp default CURRENT_TIMESTAMP")
	private Timestamp inTime;
	@OneToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "in_user")
	private User inUser;

	// 任务id
	@OneToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "task_id")
	private Task task;
	// 代码地址
	private String git;
	// 任务日志
	@Column(length = 21317)
	@NotEmpty(message = "请如实提交作业运行效果截图、代码截图或文字描述")
	@Length(message = "上传的字数太多, 请改成截图方式提交！", max = 21317)
	private String log;
	// 进度
	private Byte progress;
	@Column(columnDefinition = "timestamp")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Timestamp finishAt;

	private String state;
	@Column(columnDefinition = "timestamp")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Timestamp checkAt;

//	@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
//	@JoinColumn(name = "rela_id")
//	private List<Upload> files;

}
